package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsGridProcessStep;
import com.econ.powercloud.ems.dal.mapper.EmsGridProcessStepMapper;
import org.springframework.stereotype.Repository;

import java.util.Collections;
import java.util.List;


/**
 * @author jwc
 * @date 2022/08/10
 */
@Repository
public class EmsGridProcessStepDAO extends ServiceImpl<EmsGridProcessStepMapper, EmsGridProcessStep> {

    public EmsGridProcessStep selectByProcessNodeIdAndOrderNum(Long processNodeId, Integer orderNum) {
        LambdaQueryWrapper<EmsGridProcessStep> wrapper = Wrappers.<EmsGridProcessStep>lambdaQuery()
                .eq(EmsGridProcessStep::getProcessNodeId, processNodeId).eq(EmsGridProcessStep::getOrderNum, orderNum);
        return baseMapper.selectOne(wrapper);
    }

    public List<EmsGridProcessStep> selectListByProcessStepIds(List<Long> processNodeIds){
        if(CollectionUtils.isEmpty(processNodeIds)){
            return Collections.emptyList();
        }
        LambdaQueryWrapper<EmsGridProcessStep> wrapper = Wrappers.<EmsGridProcessStep>lambdaQuery();
        wrapper.in(EmsGridProcessStep::getId,processNodeIds);
        return baseMapper.selectList(wrapper);
    }
}